﻿using ATSimData.PaymentCallbackRecord;
using BCCommon.PaymentEnums;
using BCEntity.Common.Payment.PaymentCallbackRecord;

namespace BCService.Common.Payment.PaymentCallbackRecord
{
    /// <summary>
    /// 公共支付回调记录服务
    /// </summary>
    public class CommonPaymentCallbackRecordService : ICommonPaymentCallbackRecordService
    {
        private readonly IPaymentCallbackRecordData paymentCallbackRecordData;

        public CommonPaymentCallbackRecordService(IPaymentCallbackRecordData paymentCallbackRecordData)
        {
            this.paymentCallbackRecordData = paymentCallbackRecordData;
        }
        /// <summary>
        /// 添加支付回调记录
        /// </summary>
        /// <param name="payChannelType">支付渠道类型</param>
        /// <param name="UserId">用户Id</param>
        /// <param name="dataParameters">请求参数</param>
        /// <returns></returns>
        public long Add(PaymentChannelType payChannelType, long UserId,string dataParameters)
        {
            PaymentCallbackRecordEntity entity = new PaymentCallbackRecordEntity();
            entity.PayChannelType = payChannelType;
            entity.UserId = UserId;
            entity.DataParamters = dataParameters;
            return this.paymentCallbackRecordData.Add(entity);
        }
        /// <summary>
        /// 添加代理商支付回调记录
        /// </summary>
        /// <param name="payChannelType">支付渠道类型</param>
        /// <param name="adminId">管理员id</param>
        /// <param name="dataParameters">请求参数</param>
        /// <returns></returns>
        public long AgentAdd(PaymentChannelType payChannelType, long adminId, string dataParameters)
        {
            PaymentCallbackRecordEntity entity = new PaymentCallbackRecordEntity();
            entity.PayChannelType = payChannelType;
            entity.AdminId =adminId;
            entity.DataParamters = dataParameters;
            return this.paymentCallbackRecordData.Add(entity);
        }

        /// <summary>
        /// 更新备注内容
        /// </summary>
        /// <param name="paymentCallbackRecordId">支付回调记录Id</param>
        /// <param name="remakeContent">备注内容</param>
        /// <returns></returns>
        public bool UpdateRemakeContent(long paymentCallbackRecordId, string remakeContent)
        {
            return this.paymentCallbackRecordData.UpdateRemakeContent(paymentCallbackRecordId, remakeContent);
        }

        /// <summary>
        /// 更新支付回调记录状态
        /// </summary>
        /// <param name="paymentCallbackRecordId">支付回调记录Id</param>
        /// <returns></returns>
        public bool UpdateStatus(long paymentCallbackRecordId)
        {
            return this.paymentCallbackRecordData.UpdateStatus(paymentCallbackRecordId);
        }
    }
}
